#include <iostream>
#include <vector>

using namespace std;

class Solution 
{
public:
    vector<int> twoSum(vector<int>& numbers, int target) 
    {
        int left = 0;
        int right = numbers.size() - 1;

        while (left < right)
        {
            int n = numbers[left] + numbers[right];
            if (n == target)
            {
                return { left,right };
            }
            else if (n < target)
            {
                left++;
            }
            else
            {
                right--;
                left = 0;
            }
        }
        return { -1,-1 };
    }
};
int main()
{
    vector<int> v1{ 1,2,4,6,10 };
    int n = 8;

    Solution xz;
    vector<int> v = xz.twoSum(v1, n);

    for (auto e : v)
    {
        cout << e << ' ';
    }
	return 0;
}